<%
  url_options ||= params_for(action: :index, id: nil, search: nil)
  submit_text ||= :search
  xhr ||= request.xhr?
  options = {
    id: element_form_id(action: 'search'),
    class: 'as_form search',
    remote: xhr,
    data: {loading: true},
    method: :get
  }
  options[:class] += ' floating-footer' if active_scaffold_config.field_search.floating_footer
  
  hidden_params = url_options.except(:controller, :action, :id, :search).to_query.split(Rack::Utils::DEFAULT_SEP)
-%>

<%= form_tag url_options, options %>
  <% hidden_params.each do |pair| -%>
    <% key, value = pair.split('=', 2).map { |str| Rack::Utils.unescape(str) } -%>
    <%= hidden_field_tag(key, value) %>
  <% end -%>

  <%= render 'field_search_columns', columns: active_scaffold_config.field_search.columns %>

  <p class="form-footer">
    <%
      reset_attrs = {class: 'reset'}
      if active_scaffold_config.field_search.reset_form
        reset_attrs[:data] = {reset: true}
      else
        reset_attrs[:class] += ' as_cancel'
        reset_attrs.merge! remote: true, data: {refresh: true}
      end
    %>
    <%= submit_tag as_(submit_text), class: 'submit' %>
    <%= link_to as_(:reset), url_for(url_options.merge(search: '')), reset_attrs unless local_assigns[:skip_reset] %>
    <%= loading_indicator_tag(action: :search) %>
  </p>
</form>
